<template>
  <div>
    <div ref="echartsRef" style="width: 880px; height: 500px;"></div>
  </div>
</template>

<script setup lang="ts">
// 引入echarts
import * as echarts from 'echarts'
import { onMounted, ref } from "vue";
import  request  from "@/util/request";
// 获取div的dom 元素
const echartsRef = ref(null)

const getOption = async () => {
  const { data, meta } = await request({
    url: `/reports/type/1`,
    method: 'GET',
  })
  // 配置信息
  const option = {
    title: {
      text: '用户来源'
    },
    tooltip: {
      trigger: 'axis',
      axisPointer: {
        type: 'cross',
        label: {
          backgroundColor: '#E9EEF3'
        }
      }
    },
    grid: {
      left: '3%',
      right: '4%',
      bottom: '3%',
      containLabel: true
    },
    xAxis: [
      {
        boundaryGap: false
      }
    ],
    yAxis: [
      {
        type: 'value'
      }
    ]
  }
  // 初始化一个echarts的图
  const chart = echarts.init(echartsRef.value)
  console.log(data)
  Object.assign(option,data)
  console.log(option)
  chart.setOption(option)
}
onMounted(() => {
  // 获取配置信息
  getOption()
}
)
</script>

<style scoped>
.el-col{
  border: 1px solid #000;
}
</style>
